$(function () {
	$('.tab-group').on('click', 'span', function () {
		$(this).addClass('on').siblings().removeClass('on')
	})
	var mySwiper = new Swiper('.swiper-container', {
		loop: false,
		autoplay: 3000,
		autoplayDisableOnInteraction: false,
		autoplayStopOnLast: false,
		pagination: '.swiper-pagination',
		paginationClickable: true,

		paginationBulletRender: function (swiper, index, className) {
			return '<span class="' + className + '">' + (index + 1) + '</span>';
		}

	})
	//鼠标覆盖停止自动切换
	mySwiper.container[0].onmouseover = function () {
		mySwiper.stopAutoplay();
	}
	//鼠标移出开始自动切换
	mySwiper.container[0].onmouseout = function () {
		mySwiper.startAutoplay();
	}

	function showLine() {
		var myChart = echarts.init(document.getElementById('line-charts'));
		var option = {
			title: {
				subtext: '单位：家',
				left: '3%',
				subtextStyle: {
					color: '#666666'
				}
			},
			tooltip: {
				trigger: 'axis',
				formatter: function (params) {
					var res = '';
					for (var i = 0; i < params.length; i++) {
						var param = params[i];
						if (param.seriesName == '隐患整改率') {
							var item = param.seriesName + ":" + param.data + '%';
						} else {
							var item = param.seriesName + ":" + param.data;
						}
						res += '' + item + '</br>';
					}

					return res;
				}
			},
			legend: {
				data: [
					'总隐患数', '未整改隐患数', '超期未整改隐患数', '隐患整改率'
				],
				top: '3%'
			},
			grid: {
				left: '3%',
				right: '6%',
				bottom: '4%',
				containLabel: true
			},

			xAxis: {
				type: 'category',
				show: true,
				boundaryGap: true, //在图中间,图形对称
				axisLine: {
					show: true,
					lineStyle: {
						color: '#1178c9'
					}
				},

				axisLabel: {
					//interval:0,				//x轴标签全部显示
					textStyle: {
						color: '#333',
						fontSize: 12
					}
				},
				splitLine: {
					show: true
				},
				data: [
					'201601',
					'201602',
					'201603',
					'201604',
					'201605',
					'201606',
					'201607',
					'201608',
					'201609',
					'2016010',
					'2016011',
					'2016012',


				]
			},
			yAxis: [{
				type: 'value',
				min: 0,
				max: 'dataMax',
				axisLine: {
					show: true,
					lineStyle: {
						color: '#1178c9'
					}
				},
				axisLabel: {
					textStyle: {
						color: '#666'
					}
				},
				axisTick: {
					show: false
				},
				splitArea: {
					interval: 'auto',
					show: true,
					areaStyle: {
						color: ['#F8F8F8', '#fff']
					}
				},
				splitLine: {
					show: false

				}
			}, {
				splitLine: {
					show: false,
				},
				axisLine: {
					show: true,
					lineStyle: {
						color: '#1178c9'
					}
				},

				splitArea: {
					interval: 'auto',
					show: true,
					areaStyle: {
						color: ['#F8F8F8', '#fff']
					}
				},
				type: 'value',
				// name: '整改率',        //y轴单位
				min: 0,
				max: 100,

				axisLabel: {
					formatter: '{value} %',
					textStyle: {
						color: '#666'
					}

				}
			}],
			color: [
				'#0d80fe',
				'#f5a623',
				'#e51c23',
				'#f1421e'


			],
			series: [

				{
					name: '总隐患数',
					type: 'bar',
					stack: '1',
					//barWidth:'10',
					data: [
						40,
						12,
						11,
						34,
						20,
						20,
						40,
						12,
						21,
						34,
						32,
						20


					]
				}, {
					name: '未整改隐患数',
					type: 'bar',
					stack: '2',
					//barWidth:'10',
					data: [
						20,
						12,
						50,
						24,
						20,
						40,
						40,
						12,
						31,
						34,
						11,
						20


					]
				}, {
					name: '超期未整改隐患数',
					type: 'bar',
					stack: '3',
					//barWidth:'10',
					data: [
						10,
						22,
						20,
						14,
						39,
						30,
						40,
						12,
						11,
						34,
						30,
						20

					]
				}, {
					name: '隐患整改率',
					type: 'line',
					stack: '4',

					data: [
						22,
						42,
						11,
						34,
						39,
						33,
						40,
						12,
						19,
						34,
						11,
						20

					]

				}
			]
		};

		myChart.setOption(option);

		$(window).resize(function () {
			myChart.resize();
		});

	}

	function showBar() {
		var myChart = echarts.init(document.getElementById('bar1'));
		var option = {
			title: {
				subtext: '单位：家',
				left: '3%',
				subtextStyle: {
					color: '#666666'
				}
			},
			tooltip: {
				trigger: 'axis',
				axisPointer: { // 坐标轴指示器，坐标轴触发有效
					type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
				}
			},
			legend: {
				data: [
					'总隐患数', '未整改隐患数', '超期未整改隐患数'
				],
				top: '3%'
			},
			grid: {
				left: '3%',
				right: '4%',
				bottom: '3%',
				containLabel: true
			},
			xAxis: [{
				type: 'category',
				data: [
					'宜宾市',
					'德阳市',
					'广元市',
					'南充市',
					'泸州市',
					'达州市'
				],
				axisLine: {
					show: true,
					lineStyle: {
						color: '#1178c9'
					}
				},
				axisLabel: {
					textStyle: {
						color: '#333',
						fontSize: 12
					},
					interval: 0
				}
			}],
			yAxis: {
				type: 'value',
				min: 0,

				axisLine: {
					show: true,
					lineStyle: {
						color: '#1178c9'
					}
				},
				axisLabel: {
					textStyle: {
						color: '#666'
					}
				},
				axisTick: {
					show: false
				},
				splitArea: {
					interval: 'auto',
					show: true,
					areaStyle: {
						color: ['#F8F8F8', '#fff']
					}
				},
				splitLine: {
					show: false
				}
			},
			series: [{
				name: '总隐患数',
				type: 'bar',
				stack: '1',

				data: [
					30,
					32,
					11,
					24,
					20,
					25

				]
			}, {
				name: '未整改隐患数',
				type: 'bar',
				stack: '2',
				data: [
					20,
					12,
					11,
					14,
					20,
					25

				]
			}, {
				name: '超期未整改隐患数',
				type: 'bar',
				data: [
					12,
					12,
					21,
					90,
					32,
					30
				]
			}],
			color: ["#0d80fe", "#f5a623", "#e51c23"]
		};
		myChart.setOption(option);
		$(window).resize(function () {
			myChart.resize();
		});
	}

	showBar();
	showLine();

})